package com.example.huadi1.controller;

import com.example.huadi1.service.DepartmentService;
import com.example.huadi1.utils.AjaxResult;
import com.example.huadi1.utils.Request.SinglePageRequest;
import com.example.huadi1.utils.Request.PageRequest;
import com.example.huadi1.utils.Request.IntList;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/department")
@Slf4j
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    @PostMapping ("/demand")
    public AjaxResult getDemands(@RequestBody PageRequest pageRequest){
        AjaxResult result=departmentService.getDemandById(pageRequest);
        return result;
    }

    @PostMapping("/confirm")
    public AjaxResult confirm(@RequestBody IntList intList){
        AjaxResult result=departmentService.confirmById(intList);
        return result;
    }
    @PostMapping("/allDemand")
    public AjaxResult allDemand(@RequestBody SinglePageRequest singlePageRequest){
        AjaxResult result=departmentService.getAllDemand(singlePageRequest);
        return result;
    }
    @PostMapping("/reject")
    public AjaxResult reject(@RequestBody IntList intList){
        AjaxResult result=departmentService.rejectDemandById(intList);
        return result;
    }
    @PostMapping("/success")
    public AjaxResult success(@RequestBody IntList intList){
        AjaxResult result=departmentService.acceptDemandById(intList);
        return result;
    }
    @PostMapping ("/demandPass")
    public AjaxResult getDemandPass(@RequestBody PageRequest pageRequest){
        AjaxResult result=departmentService.getDemandById(pageRequest);
        return result;
    }

}
